<%layout("/common/layout.html"){%>

<%include("/common/head.html"){}%>

<div class="am-g am-text-center">
    <ol class="am-breadcrumb">
        <li><a href="${base}/">首页</a></li>
        <li><a href="#">${book.category.sort.name}</a></li>
        <li><a href="${base}/book/listBook?category=${book.category.id}&page=1">${book.category.name}</a></li>
        <li class="am-active">${book.name}</li>
    </ol>
</div>


<div class="am-container">
    <div class="am-panel am-panel-default">
        <div class="am-g blog-content">
            <div class="am-u-sm-7 am-text-center">
                <h2>${book.name}</h2>

                <p>作者: ${book.author}</p>

                <p>出版社: ${book.publish}</p>

                <p>主人: ${book.user.name}</p>


                <%if(book.type==0){%>
                <p>出售</p>

                <p>价格: ${book.price}块</p>
                <%}else if(book.type==1){%>
                <p>求购</p>

                <p>出价: ${book.price}块</p>
                <%}else{%>
                <p>出售</p>

                <p>条件:
                    <%if(book.msg==null){%>无<%}else{%>${book.method}<%}%>
                </p>
                <%}%>

            </div>
            <div class="am-u-sm-5">
                <p><img src="${book.img}"></p>
            </div>
        </div>
        <div class="am-kai book-info">
            <p>${book.content}</p>
        </div>
    </div>

    <div class="am-lg am-text-center">
        <button class="am-btn am-btn-primary" data-am-modal="{target: '#message'}">联系方式</button>
    </div>

    <div class="am-modal am-modal-alert" tabindex="-1" id="message">
        <div class="am-modal-dialog">
            <div class="am-modal-hd">联系方式</div>
            <div class="am-modal-bd">
                ${book.contact}
            </div>
            <div class="am-modal-footer">
                <span class="am-modal-btn">确定</span>
            </div>
        </div>
    </div>

    <br>

    <%for (post in page.list){%>

    <div class="am-comment-main">
        <header class="am-comment-hd">
            <div class="am-comment-meta">
                <a href="${base}/user/info?user=${post.user.id}" class="am-comment-author">${post.user.name}</a>
                评论于${printTime(post.time)}
            </div>
        </header>
        <div class="am-comment-bd"><p>
            ${post.content}</p>
        </div>
    </div>

    <br>

    <%}%>

    <div class="am-lg am-text-center">

        <button class="am-btn am-btn-primary" data-am-modal="{target: '#my-alert'}">回复</button>
    </div>


    <div class="am-modal am-modal-alert" tabindex="-1" id="my-alert">
        <div class="am-modal-dialog">
            <div class="am-modal-hd">新回复</div>
            <div class="am-modal-bd">
                <form action="${base}/book/addPost">
                    <div class="am-input-group">
                        <input type="hidden" name="book" value="${book.id}">
                        <input type="text" name="content" class="am-form-field">
                        <span class="am-input-group-btn">
                            <button class="am-btn am-btn-default" type="submit">提交</button>
                        </span>
                    </div>

                </form>
            </div>
            <div class="am-modal-footer">
                <span class="am-modal-btn">取消</span>
            </div>
        </div>
    </div>


    <%include("/common/paginate.html",{"currentPage":page.pageNumber,"totalPage":page.totalPage,"actionUrl":actionUrl!}) {}%>

</div>


<%}%>